<script>
	/**
	 * vuex管理登录状态，具体可以参考官方登录模板示例
	 */
	import {
		mapMutations
	} from "vuex";
	import {
		getClipboardData
	} from "@/js_sdk/h5-copy/h5-copy.js";
	import config from "@/config/config";
	// 悬浮球

	export default {
		data() {
			return {
				config,
			};
		},
    globalData: {
			clientId: '',
			username: '',
			password: ''
		},

		/**
		 * 监听返回
		 */
		onBackPress(e) {
			if (e.from == "backbutton") {
				let routes = getCurrentPages();
				let curRoute = routes[routes.length - 1].options;
				routes.forEach((item) => {
					if (
						item.route == "pages/tabbar/cart/cartList" ||
						item.route.indexOf("pages/product/goods") != -1
					) {
						uni.redirectTo({
							url: item.route,
						});
					}
				});

				if (curRoute.addId) {
					uni.reLaunch({
						url: "/pages/tabbar/cart/cartList",
					});
				} else {
					uni.navigateBack();
				}
				return true; //阻止默认返回行为
			}
		},
		methods: {
			...mapMutations(["login"]),
		},

		onLaunch: function(options) {
      // #ifdef APP-PLUS
			this.checkArguments(options.query); // 检测启动参数
		},

		onShow() {

		},
		methods: {

			/**
			 * 跳转过来的信息存到全局变量中
			 */
			checkArguments(data) {
				// #ifdef APP-PLUS
        if (data) {
					if (data.clientId) {
						getApp().globalData.clientId = data.clientId
					}
					if (data.username) {
						getApp().globalData.username = data.username
					}
					if (data.password) {
						getApp().globalData.password = data.password
					}
					console.log('全局的参数为：', getApp().globalData)
				}
				// #endif
			},
		},
	};
</script>

<style lang="scss">
	@import "uview-ui/index.scss";

	// -------适配底部安全区  苹果x系列刘海屏

	// #ifdef MP-WEIXIN
	.mp-iphonex-bottom {
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		box-sizing: content-box;
		height: auto !important;
		padding-top: 10rpx;
	}

	// #endif

	body {
		background-color: $bg-color;
	}

	/************************ */
	.w200 {
		width: 200rpx !important;
	}

	.flex1 {
		flex: 1; //必须父级设置flex
	}
</style>
